<?php
namespace controller;
use Core\ControllerClass;

if (defined(APP_NAME))
    exit("APP_NAME IF NOT DEFINE");
/**
 * 这个是项目自动生成的文件
 * 
 * @author HexPHP
 *        
 */
class WelcomeController extends ControllerClass
{

    public function index ()
    {
        global $array;
        echo $array['skin_par'];
        echo L('_lang_error');
        echo "<h1>Hello HexPHP ! :)</h1>";
        echo '<a href="welcome/write">write</a> | ';
        echo '<a href="welcome/reader">reader</a> | ';
        echo '<a href="welcome/say">welcome say</a> | ';
        echo '<a href="welcome/style/s/red">red</a> | ';
        echo '<a href="welcome/style/s/default">black</a>';
    }
    //测试读取
    public function reader()
    {
        $file = APP_PATH.DS.'Config'.DS.'config.ini';
        $ars =  parse_ini_file($file,true);
        var_dump($ars);
        echo $file." 中 language 的内容为".iniGet('language');
        echo "<h1>ini file reader end!</h1>";
    }
    //测试写入
    public function write(){
        
        $file = APP_PATH.DS.'Config'.DS.'config.ini';
        $accarr = array(
                'config'=>array('url_mode'=>2,'action_name'=>'a','model_name'=>'m','language'=>'zh_cn'),
                'mysql' =>array('host'=>'localhost','user'=>'root','pass'=>'root','dbname'=>'test'),
        );
        if(write_ini_file($file,$accarr)){
            echo "ini file write ok!";
        }
    }
    //测试模型
    public function say(){
        $model = $this->loadModel('welcome');
        foreach ($model->allList() as $k=>$v){
            echo $k ."=>".$v."<br />";
        }
    }
    //测试视图
    public function style()
    {
        $style = $this->input->get('s');
        $this->skin($style);
        $this->display('index');
    }
}
//end welcomecontroller.php